import { Dispatch } from 'redux';
import { setLoading } from './app';

const delay = (ms: number) => new Promise((res) => setTimeout(res, ms));

export enum ActionType {
    ADD_COUNT = 'ADD_COUNT',
}

export const addCountAsync = () => async (dispatch: Dispatch) => {
    dispatch(setLoading(true));
    await delay(1000);
    dispatch(setLoading(false));
    dispatch({
        type: ActionType.ADD_COUNT,
    });
};
